public class Solution1247 {
    public int minimumSwap(String s1, String s2) {
        int a=0,b=0,ans=0;
        for (int i=0;i<s1.length();i++){
            if (s1.charAt(i)=='x' && s2.charAt(i)=='y'){
                a++;
                if (a==2){
                    ans++;
                    a=0;
                }
            }else if (s1.charAt(i)=='y' && s2.charAt(i)=='x'){
                b++;
                if (b==2){
                    ans++;
                    b=0;
                }
            }
        }
        if (a==0 && b!=0 || b==0 && a!=0){
            return -1;
        }
        if (a==1 && b==1){
            ans+=2;
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1247().minimumSwap("xy","yx"));
    }
}
